(ns conv-proxy.core
  (:gen-class)
  (:require [clojure.string :as str]
            [clojure.java.io :as io :only resource]))

(defn main-process
  [m-list x]
  (spit (str (x 1) ".txt") 
        (->> m-list
           (filter #(= (% 0) (x 0)))
           (map #(conj [] (str/replace (% 2) #"\ " "") (% 1) (% 4)))
           (map #(str/join "|" %))
           (str/join "\n"))))

(defn -main
  "I don't do a whole lot ... yet."
  [& args]
  (println "Hello, World!")
  (let [name-list (->>
                    (slurp (io/resource "dep.txt"))
                    (str/split-lines)
                    (map #(str/split % #"\^")))
        map-selected (->> (slurp (first args))
                          (str/split-lines)
                          (map #(str/split % #"\^"))
                          (map #(conj [] (% 1) (% 6) (% 7) (% 8) (% 39))))]
    (dorun (map (fn [x] (main-process map-selected x)) name-list))))
